package com.bwie.controller;

import cn.hutool.core.lang.tree.Tree;
import cn.hutool.core.lang.tree.TreeUtil;
import com.bwie.pojo.Menu;
import com.bwie.service.MenuService;
import com.bwie.service.UserService;
import com.bwie.utils.Result;
import com.bwie.vo.LoginForm;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.License;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @projectName: server-day0718-pay
 * @package: com.bwie.controller
 * @className: UserController
 * @author: 陈彤彤
 * @description: TODO
 * @date: 2025/7/18 14:41
 * @version: 1.0
 */
@RestController
@RequestMapping("/user/user")
@Api(tags = "用户登录管理")
public class UserController {

    @Autowired
    UserService userService;

    @Autowired
    MenuService menuService;

    /**
    * @param loginForm:
    * @return Result
    * @author :陈彤彤
    * @description 发送短信验证码
    * @date 2025/7/18 17:06
    */
    @ApiOperation(value = "发送短信验证码")
    @PostMapping("/sendPhoneCode")
    public Result sendPhoneCode(@RequestBody LoginForm loginForm){
        return userService.sendPhoneCode(loginForm);
    }

    /**
    * @param loginForm:
    * @return Result
    * @author :陈彤彤
    * @description 手机号注册
    * @date 2025/7/18 17:18
    */
    @ApiOperation(value = "手机号注册")
    @PostMapping("/userReg")
    public Result userReg(@RequestBody LoginForm loginForm){
        return userService.userReg(loginForm);
    }

    /**
    * @param loginForm:
    * @return Result
    * @author :陈彤彤
    * @description 手机号密码登录
    * @date 2025/7/18 17:28
    */
    @ApiOperation(value = "手机号密码登录")
    @PostMapping("/phoneLogin")
    public Result phoneLogin(@RequestBody @Validated LoginForm loginForm){
        return userService.phoneLogin(loginForm);
    }

    /**
    * @param :
    * @return Result
    * @author :陈彤彤
    * @description 获取动态导航侧边栏
    * @date 2025/7/20 20:23
    */
    @ApiOperation(value = "获取动态导航侧边栏")
    @PostMapping("/menuList")
    public Result menuList(){
       return userService.menuList();
    }

}
